<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>优车处置附加信息页面</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <jsp:include page="../assParking/assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->
    <jsp:include page="../assCommFilesList1.jsp" flush="true" ></jsp:include>
    <style>
        span.title {
            font-size: 15px;
        }

        span.sq-button-round {
            height: 23px !important;
        }

        i.ico_flasher {
            height: 29px;
            vertical-align: middle;
        }
    </style>
</head>
<body class="iframeBody">
<jsp:include page="../assCommFilesUpload1.jsp" flush="true" >
    <jsp:param name="filePath" value="ass"/>
</jsp:include>
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <!-- 页签1：优车处置申请 -->
            <div tabid="tabA" title="优车处置附加信息" lselected="true">
                <form id="yc_dealCar">
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="fieldBox col_33">
                            <div class="label">申请人</div>
                            <div class="field">
                                <span id="applyNm" name="applyNm"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">申请时间</div>
                            <div class="field">
                                <span id="applyDt" name="applyDt"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">拖车标记</div>
                            <div class="field">
                                <span id="backedFlagCd" name="backedFlagCd"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">车辆交接单</div>
                            <div class="field">
                                <a class="modify Hide" href="javascript:void(0);" onclick="entryOrder('out')">出库</a>
                                <a class="detail" href="javascript:void(0);" onclick="entryOrder('detail')">查看</a>
                                <a href="javascript:void(0);" onclick="exportAssCarHvPdf()" style="margin-left: 30px;">导出</a>
                            </div>
                        </div>

                        <!-- 车辆出入库资料  -->
                        <div class="caption crkzl">
                            <span class="title">车辆出入库资料</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div style="width: 98%; margin-left: 1%;">
                                <div id="ligergrid_file0" class="sq-grid"></div>
                            </div>
                        </div>

                        <div class="caption">
                            <div class="btnsBox posL">
                                <span class="sq-button sq-button-round Hide" onclick="editAssessAmt()"><i class="ico_flasher"></i>编辑</span>
                            </div>
                            <span class="title">评估信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">车辆评估价(元)</div>
                            <div class="field">
                                <span id="assessAmt" name="assessAmt" style="font-size:16px;"></span>
                            </div>
                        </div>

                        <div class="caption">
                            <div class="btnsBox posL">
                                <span class="sq-button sq-button-round Hide" onclick="editDealSell()"><i class="ico_flasher"></i>编辑</span>
                                <span class="sq-button sq-button-round Hide" onclick="editAccStsCd()"><i class="ico_flasher"></i>编辑</span>
                                <span class="sq-button sq-button-round Hide" onclick="editBuyerCode()"><i class="ico_flasher"></i>编辑</span>
                            </div>
                            <span class="title">处置信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">拍卖状态</div>
                            <div class="field">
                                <input name="auctionStsCd" id="auctionStsCd" data-value="" placeholder="请选择" ltype="combobox" ligerui="width: 160"/>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">到账状态</div>
                            <div class="field">
                                <input name="toAccStsCd" id="toAccStsCd" data-value="" placeholder="请选择" ltype="combobox" ligerui="width: 160"/>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">处置接收人类型</div>
                            <div class="field">
                                <input name="buyerTypeCd" id="buyerTypeCd" data-value="" placeholder="请选择" ltype="combobox" ligerui="width: 160"/>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">成交时间</div>
                            <div class="field">
                                <span id="ycDealTm" name="ycDealTm"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">优车销售经理</div>
                            <div class="field">
                                <span id="sellManager" name="sellManager" style="color:blue;"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">处置金额(元)</div>
                            <div class="field">
                                <span id="sellAmt" name="sellAmt" style="font-size:16px;"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">佣金(元)</div>
                            <div class="field">
                                <span id="commissionAmt" name="commissionAmt" style="font-size:16px;"></span>
                            </div>
                        </div>
                        <!-- 个人信息 -->
                        <div class="fieldBox col_33 person Hide">
                            <div class="label">处置接收人姓名</div>
                            <div class="field">
                                <span id="buyerNm" name="buyerNm"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 person Hide">
                            <div class="label">处置接收人证件号</div>
                            <div class="field">
                                <span id="buyerCd" name="buyerCd"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 person Hide">
                            <div class="label">联系方式</div>
                            <div class="field">
                                <span id="buyerTel" name="buyerTel"></span>
                            </div>
                        </div>
                        <!-- 企业信息 -->
                        <div class="fieldBox col_33 company Hide">
                            <div class="label">处置接收企业名称</div>
                            <div class="field">
                                <span id="buyerCompanyNm" name="buyerCompanyNm"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 company Hide">
                            <div class="label">处置接收企业联系人</div>
                            <div class="field">
                                <span id="buyerCompanyContact" name="buyerCompanyContact"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 company Hide">
                            <div class="label">联系方式</div>
                            <div class="field">
                                <span id="buyerCompanyTel" name="buyerCompanyTel"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 company Hide">
                            <div class="label">组织机构代码证</div>
                            <div class="field">
                                <span id="buyerCompanyCode" name="buyerCompanyCode"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">备注信息</div>
                            <div class="field">
                                <span name="sellDesc" id="sellDesc"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_100 btnsBox">
                        </div>

                        <!-- 付款信息 -->
                        <div class="caption">
                            <div class="btnsBox posL">
                                <span class="sq-button sq-button-round Hide" onclick="editPayInfo('')"><i class="ico_flasher"></i>添加</span>
                            </div>
                            <span class="title">付款方</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="sqPanel">
                                <div id="payInfoDataGrid" class="sq-grid"></div>
                            </div>
                        </div>
                        <div id="payUploadDiv" class="fieldBox col_100 Hide">
                            <div class="label">来款凭证上传</div>
                            <div class="field">
                                <div id="fileUpload2" class="upfileBoxs"></div>
                                <span class="sq-button sq-button-hasicon" id="btnUpload2" onclick="saveAndUploadFile('uploads2', 2, 'lkpz_cz')">
							        <i class="sqBtnIco_9"></i>上传
							    </span>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div style="width: 98%; margin-left: 1%;">
                                <div id="ligergrid_file2" class="sq-grid"></div>
                            </div>
                        </div>

                        <!-- 收款信息 -->
                        <div class="caption">
                            <div class="btnsBox posL">
                                <span class="sq-button sq-button-round Hide" onclick="editReceiveInfo()"><i class="ico_flasher"></i>编辑</span>
                            </div>
                            <span class="title">收款方</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">收款银行</div>
                            <div class="field">
                                <span name="payeeBankNm" id="payeeBankNm"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">收款账号</div>
                            <div class="field">
                                <span name="payeeAccNo" id="payeeAccNo"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">收款方名称</div>
                            <div class="field">
                                <span name="payeeAccNm" id="payeeAccNm"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_100"></div>
                        <div class="fieldBox col_33">
                            <div class="label">二次评估价(元)</div>
                            <div class="field">
                                <span id="baseAmt" name="baseAmt">${baseAmt}</span>
                            </div>
                        </div>

                        <!-- 提车人信息 -->
                        <div class="caption fkxx">
                            <div class="btnsBox posL">
                                <span class="sq-button sq-button-round Hide" onclick="editSellPickInfo()"><i class="ico_flasher"></i>编辑</span>
                            </div>
                            <span class="title">提车人信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">提车人姓名</div>
                            <div class="field">
                                <span id="pickCarNm" name="pickCarNm"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">提车人联系电话</div>
                            <div class="field">
                                <span id="pickCarTel" name="pickCarTel"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">提车人身份证号</div>
                            <div class="field">
                                <span id="pickCarCd" name="pickCarCd"></span>
                            </div>
                        </div>
                        <div id="pickCarUploadDiv" class="fieldBox col_100 Hide">
                            <div class="label">附件上传</div>
                            <div class="field">
                                <div id="fileUpload3" class="upfileBoxs"></div>
                                <span class="sq-button sq-button-hasicon" id="btnUpload3" onclick="saveAndUploadFile('uploads3', 3, 'cztcr')">
							        <i class="sqBtnIco_9"></i>上传
							    </span>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div style="width: 98%; margin-left: 1%;">
                                <div id="ligergrid_file3" class="sq-grid"></div>
                            </div>
                        </div>

                        <!-- 提报费用信息 -->
                        <div class="caption">
                            <div class="btnsBox posL">
                                <span class="sq-button sq-button-round Hide" onclick="toEditCost('')"><i class="ico_flasher"></i>添加</span>
                            </div>
                            <span class="title">提报费用信息</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="sqPanel">
                                <div id="ligergrid2" class="sq-grid"></div>
                            </div>
                        </div>

                        <!-- 付款信息 -->
                        <div class="caption">
                            <div class="btnsBox posL">
                                <span class="sq-button sq-button-round Hide" onclick="editBfsPayInfo()"><i class="ico_flasher"></i>编辑</span>
                            </div>
                            <span class="title">付款信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">应付金额(元)</div>
                            <div class="field">
                                <span id="shouldPayAmt" name="shouldPayAmt" style="font-size:16px;"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">付款方式</div>
                            <div class="field">
                                <span id="payWayCd" name="payWayCd">手动付款</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">实付金额(元)</div>
                            <div class="field">
                                <span id="bfsPayAmt" name="bfsPayAmt" style="font-size:16px;">123456</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">实付时间</div>
                            <div class="field">
                                <span id="bfsPayTm" name="bfsPayTm"></span>
                            </div>
                        </div>


                        <!-- 隐藏支付表主键、支付表号 -->
                        <div class="fieldBox col_100" style="display:none;">
                            <div class="field">
                                <input name="deal_Id" id="deal_Id" type="text" class="ui-textbox" value="${ycDealId}">
                                <input name="taskDefKey" id="taskDefKey" type="text" class="ui-textbox" value="${taskDefKey}">

                                <input name="tcMasterId" id="tcMasterId" type="text" class="ui-textbox" value="">
                                <input name="tcDetailId" id="tcDetailId" type="text" class="ui-textbox" value="">

                                <input name="wsPaySchId" id="wsPaySchId" type="text" class="ui-textbox" value="">
                                <input name="wsPaySchNo" id="wsPaySchNo" type="text" class="ui-textbox" value="">
                                <input name="flag" id="flag" type="text" class="ui-textbox" value="${flag }">
                            </div>
                        </div>
                    </div>
                </form>
                <div id="capFundBindDiv" style="height:auto;"></div>
            </div>
            <!-- 页签2：拖车单信息 -->
            <div tabid="tabB" title="拖车单信息" id="tabBId">
                <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
            </div>
        </div>
    </div>
</div>

<script>
    var basePath = "<%=path%>";
    var dealId = $("#deal_Id").val();

    $(function () {
        loadFilesLiger("lkpz_cz", 2, dealId);//加载处置来款凭证文件列表信息
        loadFilesLiger("cztcr", 3, dealId);//加载处置提车人文件列表信息

        initForm();//初始化表单
        initData();//初始化数据
        initTab();//初始化页签
    });

    //初始化表单
    function initForm() {
        $("#yc_dealCar").ligerForm({
            validate: true
        });
        $("#yc_dealCar").check_ligerFormEditor();//重新刷新页面动态字段
        // 处置接收人类型comboBox
        $("#buyerTypeCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            disabled: true,// 禁用
            data: ${buyerTypeList},
            onChangeValue: function (newValue) {
                selectBuyerTypeChange();
            }
        });
        // 拍卖状态
        $("#auctionStsCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            disabled: true,// 禁用
            data: ${auctionStsList}
        });
        // 到账状态
        $("#toAccStsCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            disabled: true,// 禁用
            data: ${toAccStsList}
        });
    }

    // 处置接受人类型onSelected事件
    function selectBuyerTypeChange() {
        var value = liger.get("buyerTypeCd").getValue();
        if (value == "") {
            $("#yc_dealCar").find(".company").each(function () {
                $(this).addClass('Hide');
            });
            $("#yc_dealCar").find(".person").each(function () {
                $(this).addClass('Hide');
            });
        } else if (value == "1") {//企业
            $("#yc_dealCar").find(".company").each(function () {
                $(this).removeClass('Hide');
            });
            $("#yc_dealCar").find(".person").each(function () {
                $(this).addClass('Hide');
            });
        } else if (value == "2") {//个人
            $("#yc_dealCar").find(".person").each(function () {
                $(this).removeClass('Hide');
            });
            $("#yc_dealCar").find(".company").each(function () {
                $(this).addClass('Hide');
            });
        }
    }

    //初始化数据
    function initData() {
        if (!dealId) {
            $.ligerDialog.SQalert({content: "处置ID为空,无法查询相关信息！", SQ_type: "error"});
            return;
        }
        $.ajax({
            type: 'get',
            dataType: 'json',
            data: {dealId: dealId},
            url: basePath + '/ass/ucardeal/queryFlowPageDetail.do',
            success: function (msg) {
                if (msg.success == 1) {
                    setData(msg.data);//设置数据
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //设置页面数据
    function setData(data) {

        setSellInfo(data.dealCar, data.dealSell);

        $("#sellDesc").html(data.dealSell.sellDesc);
        // 收款方信息
        $("#payeeBankNm").html(data.dealSell.payeeBankNm);
        $("#payeeAccNo").html(data.dealSell.payeeAccNo);
        $("#payeeAccNm").html(data.dealSell.payeeAccNm);

        // 提车人信息
        $("#pickCarNm").html(data.dealSell.pickCarNm);//提车人姓名
        $("#pickCarTel").html(data.dealSell.pickCarTel);//提车人联系电话
        $("#pickCarCd").html(data.dealSell.pickCarCd);//提车人联系电话

        //显示申请信息
        $("#applyNm").html(data.dealSell.applyNm);
        $("#applyDt").html(renderDate1(data.dealSell.crtTm));
        $("#backedFlagCd").html(data.dealSell.backedFlagCd);

        //设置拖车信息主键值
        $("#tcMasterId").val(data.dealSell.masterId);
        $("#tcDetailId").val(data.dealSell.detailId);

        $("#wsPaySchId").val(data.wsPaySchId);
        $("#wsPaySchNo").val(data.wsPaySchNo);

        loadFilesLiger("crkzl", 0, data.dealSell.detailId);//加载出入库文件列表信息
    }

    function setSellInfo(dealCar, dealSell) {
        //加载表单
        var form = liger.get("yc_dealCar");
        form.setData({
            auctionStsCd: dealCar.auctionStsCd,// 拍卖状态
            toAccStsCd: dealSell.toAccStsCd,// 到账状态
            buyerTypeCd: dealSell.buyerTypeCd
        });
        $("#sellAmt").html(dealSell.sellAmt == null ? '' : FormatMoney(dealSell.sellAmt / 100));
        $("#assessAmt").html(dealSell.assessAmt == null ? '' : FormatMoney(dealSell.assessAmt / 100));
        $("#commissionAmt").html(dealSell.commissionAmt == null?'':FormatMoney(dealSell.commissionAmt / 100));
        $("#buyerNm").html(dealSell.buyerNm);
        $("#buyerCd").html(dealSell.buyerCd);
        $("#buyerTel").html(dealSell.buyerTel);
        $("#buyerCompanyNm").html(dealSell.buyerCompanyNm);
        $("#buyerCompanyContact").html(dealSell.buyerCompanyContact);
        $("#buyerCompanyTel").html(dealSell.buyerCompanyTel);
        $("#buyerCompanyCode").html(dealSell.buyerCompanyCode);
        $("#ycDealTm").html(renderDate1(dealCar.ycDealTm));
        if (dealSell.dealSellMgrId != null) {
            $("#sellManager").html(dealSell.dealSellMgrRlNm + "[" + dealSell.dealSellMgrUsrNm + "]");
        }

        $("#shouldPayAmt").html(dealSell.sellAmt == null ? '' : FormatMoney(dealSell.sellAmt / 100));
        $("#bfsPayAmt").html(dealSell.bfsPayAmt == null ? '' : FormatMoney(dealSell.bfsPayAmt / 100));
        $("#bfsPayTm").html(renderDate1(dealSell.bfsPayTm));
    }

    //初始化付款信息
    var payInfoDataGrid = $("#payInfoDataGrid").ligerGrid({
        url: basePath + '/ass/assTrailCarM/getAssDealRecAmtList.do?flag=1&dataTypeCd=1&dataId=' + dealId,
        method: 'get',
        columns: [
            {display: '银行信息', name: 'payerBankNm', minWidth: 120, align: 'center', enabledSort: false},
            {display: '账号信息', name: 'payerAccNo', minWidth: 100, align: 'center', enabledSort: false},
            {display: '付款方名称', name: 'payerAccNm', minWidth: 150, align: 'center', enabledSort: false},
            {display: '付款金额(元)', name: 'payAmt', width: 100, align: 'center', enabledSort: false,
                render: function (rowdata, index, value) {
                    return FormatMoney(value / 100);
                }
            },
            {display: '付款时间', name: 'payTm', width: 100, align: 'center', enabledSort: true,
                render: function (rowdata, rowindex, value, column) {
                    var h = renderDate1(rowdata.payTm);
                    return h;
                }
            },
            {display: '到账时间', name: 'receivedTm', width: 100, align: 'center', enabledSort: true,
                render: function (rowdata, rowindex, value, column) {
                    var h = renderDate1(rowdata.receivedTm);
                    return h;
                }
            },
            {display: '到账金额(元)', name: 'receivedAmt', width: 100, align: 'center', enabledSort: false,
                render: function (rowdata, index, value) {
                    return FormatMoney(value / 100);
                }
            },
            {display: '使用金额(元)', name: 'useAmt', width: 100, align: 'center', enabledSort: false,
                render: function (rowdata, index, value) {
                    return FormatMoney(value / 100);
                }
            },
            {display: '操作', name: '', minWidth: 150, align: 'center', enabledSort: false,
                render: function (rowdata, rowindex, value) {
                    var hide = "Hide";
                    if (rowdata.hide) {
                        hide = "";
                    }
                    var h = '';
                    h += '<a class="sq-button-hasicon ' + hide + '" style="cursor:pointer;" href="javascript:editPayInfo(';
                    h += "'" + rowdata.id + "'";
                    h += ')"><i class="sqBtnIco_4"></i>修改</a>';
                    h += '<a class="sq-button-hasicon ' + hide + '" style="cursor:pointer;" href="javascript:deletePayInfo(';
                    h += "'" + rowdata.id + "'";
                    h += ')"><i class="sqBtnIco_7"></i>删除</a>';
                    return h;
                }
            }
        ],
        //pageSize: 10,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        heightDiff: -2,
        checkbox: true,
        usePager: false,//是否分页
        rownumbers: true,
        allowUnSelectRow: true,
        alternatingRow: true
    });

    var grid2 = $("#ligergrid2").ligerGrid({
        url: basePath + '/ass/assTrailCarD/initCostList.do?CAR_ID=' + dealId,
        method: 'get',
        columns: [
            {display: '借款类型', name: 'loanTypCdNm', minWidth: 120, align: 'center', enabledSort: false},
            {
                display: '借款金额', name: 'costAmt', minWidth: 100, align: 'center', enabledSort: false,
                render: function (rowdata, index, value) {
                    return FormatMoney(value / 100);
                }
            },
            {display: '备注', name: 'costRem', minWidth: 150, align: 'center', enabledSort: false},
            {display: '流程编号', name: 'procNo', minWidth: 120, align: 'center', enabledSort: false,
                render: function (rowdata, rowindex, value) {
                    return '<a href="javascript:commShowFlow(' + rowindex + ')">' + value + '</a>';
                }
            },
            {
                display: '操作', name: '', minWidth: 150, align: 'center', enabledSort: false,
                render: function (rowdata, rowindex, value) {
                    var hide = "Hide";
                    if (rowdata.hide) {
                        hide = "";
                    }
                    var h = '<a class="sq-button-hasicon ' + hide + '" style="cursor:pointer;" href="javascript:;" onclick="toEditCost(';
                    h += "'" + rowdata.id + "'";
                    h += ')"><i class="sqBtnIco_4"></i>修改</a>';
                    h += '<a class="sq-button-hasicon ' + hide + '" style="cursor:pointer;" href="javascript:;" onclick="deleteCarCost(';
                    h += "'" + rowdata.id + "'";
                    h += ')"><i class="sqBtnIco_7"></i>删除</a>';
                    return h;
                }
            }
        ],
        pageSize: 10,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        //height: '100%',
        heightDiff: -2,
        checkbox: true,
        rownumbers: true,
        allowUnSelectRow: true,
        alternatingRow: true
    });

    function commShowFlow(rowindex) {
        var rowdata = grid2.getRow(rowindex);
        var _formUrl = "/capital/finance/loan/apply/toAddPage.do?isMust=1@@showSaveApplyBtn=0@@payDtlEditable=0@@bankAccEditable=0@@isAccount=1@@applyInfoId=",
            _pInstId = rowdata.procId;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {procId: _pInstId, table: "CAP"},
            url: basePath + '/ass/dealcar/manage/queryFlowData.do',
            success: function (msg) {
                if (msg.success == 1) {
                    var params = "?pInsId=" + _pInstId + "&status=" + msg.data.audStsCd + "&businessKey=" + msg.data.dataId + "&formUrl=" + _formUrl;
                    Add_navTab('tab_settle_look_flow_' + _pInstId, msg.data.pno, basePath + "/flow/flow/toFlowShowPageFowBus.do" + params);
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //添加付款信息
    function editPayInfo(id) {
        var onOk = function (item, Dialog) {
            if (Dialog.onOk) Dialog.onOk();
        };
        var onCancel = function (item, Dialog) {
            Dialog.hide();
        };
        var title = "编辑付款信息";
        if (StringUtils.isEmpty(id)) {
            title = "添加付款信息";
        }
        $.ligerDialog.open({
            width: 800,
            height: 360,
            title: title,
            url: basePath + '/ass/ucardeal/toRecAmtPage.do?assDealRecAmtId=' + id + "&dataId=" + dealId,
            buttons: [{
                text: "保存", type: 'ok', onclick: onOk
            }, {
                text: "关闭", type: 'cancel', onclick: onCancel, cls: 'l-dialog-btn-no'
            }],
            onClose: function() {
                payInfoDataGrid.reload();
            }
        });
    }

    function editReceiveInfo() {
        editDealSellInfo('维护收款方信息', 1, function (data) {
            // 更新收款方信息
            $("#payeeBankNm").html(data.payeeBankNm);
            $("#payeeAccNo").html(data.payeeAccNo);
            $("#payeeAccNm").html(data.payeeAccNm);
        }, 800, 300);
    }

    function editSellPickInfo() {
        editDealSellInfo('维护提车人信息', 2, function (data) {
            // 更新提车人信息
            $("#pickCarNm").html(data.pickCarNm);
            $("#pickCarTel").html(data.pickCarTel);
            $("#pickCarCd").html(data.pickCarCd);
        }, 800, 400);
    }

    function editAssessAmt() {
        editDealSellInfo('编辑车辆评估价', 3, function (data) {
            // 更新车辆评估价信息
            $("#assessAmt").html(FormatMoney(data.assessAmt/100));
        }, 500, 200);
    }

    function editDealSell() {
        editDealSellInfo('编辑优车处置信息', 4, function (data) {
            // 更新数据
            setSellInfo(data.dealCar, data);
        }, 800, 500);
    }

    function editAccStsCd() {
        editDealSellInfo('编辑到账状态', 5, function (data) {
            // 更新数据
            setSellInfo(data.dealCar, data);
        }, 500, 200);
    }

    function editBuyerCode() {
        var value = liger.get("buyerTypeCd").getValue();
        var title = "编辑组织机构代码证/处置接收人证件号";
        if (value == '1') {
            title = "编辑组织机构代码证";
        } else if (value == '2') {
            title = "编辑处置接收人证件号";
        }
        editDealSellInfo(title, 6, function (data) {
            // 更新数据
            setSellInfo(data.dealCar, data);
        }, 800, 300);
    }

    function editBfsPayInfo() {
        editDealSellInfo('编辑付款信息', 7, function (data) {
            // 更新数据
            setSellInfo(data.dealCar, data);
        }, 800, 300);
    }

    // 编辑处置信息
    function editDealSellInfo(title, type, callFunc, width, height) {
        var onOk = function (item, Dialog) {
            if (Dialog.onOk) Dialog.onOk();
        };
        var onCancel = function (item, Dialog) {
            Dialog.hide();
        };
        $.ligerDialog.open({
            width: width,
            height: height,
            title: title,
            url: basePath + '/ass/ucardeal/toEditDealSellPage.do?type=' + type + '&dealSellId=' + dealId,
            buttons: [{
                text: "保存", type: 'ok', onclick: onOk
            }, {
                text: "关闭", type: 'cancel', onclick: onCancel, cls: 'l-dialog-btn-no'
            }],
            onClose: function() {
            },
            callBack: function (data) {
                // 回调方法，更新相应的数据
                callFunc(data);
            }
        });
    }

    //删除付款信息
    function deletePayInfo(id) {
        $.ligerDialog.confirm("是否确认删除选中的付款信息数据?", function (flag) {
            if (flag == false) return;
            var wait_dialog = null;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {id: id},
                url: basePath + '/ass/assTrailCarD/deleteRecAmt.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({ content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting" });
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        payInfoDataGrid.reload();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    // 添加提报费用
    function toEditCost(id) {
        var onOk = function (item, Dialog) {
            if (Dialog.onOk) Dialog.onOk();
        };
        var onCancel = function (item, Dialog) {
            Dialog.hide();
        };
        var title = "编辑提报费用";
        if (id == '') {
            title = "添加提报费用";
        }
        $.ligerDialog.open({
            width: 900,
            height: 550,
            showMax: true,
            title: title,
            url: basePath + '/ass/ucardeal/toEditCostPage.do?id=' + id + '&carId=' + dealId,
            buttons: [{
                text: "保存", type: 'ok', onclick: onOk
            }, {
                text: "关闭", type: 'cancel', onclick: onCancel, cls: 'l-dialog-btn-no'
            }],
            onClose: function() {
                grid2.reload();
            }
        });
    }

    // 删除提报费用
    function deleteCarCost(id) {
        $.ligerDialog.confirm("是否确认删除选中的提报费用数据?", function (flag) {
            if (flag == false) return;
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {id: id},
                url: basePath + '/ass/assTrailCarD/deleteCarCost.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({ content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting" });
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        grid2.reload();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    //初始化Tab页签
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function (tabid) {
                switch (tabid) {
                    case "tabB":
                        var tcMasterId = $("#tcMasterId").val();
                        var tcDetailId = $("#tcDetailId").val();
                        var taskDefKey = $("#taskDefKey").val();
                        if (!tcDetailId || !tcMasterId) {
                            $.ligerDialog.SQalert({content: "抱歉信息不存在！", SQ_type: "warning"});
                            return false;
                        }
                        var crflag = "detail";
                        if (taskDefKey == keyNodes['009']) {
                            crflag = "out";
                        }
                        var targetUrl = basePath + "/ass/assTrailCarM/toInfoViewPage.do";
                        var reqParam = "?tcMasterId=" + tcMasterId + "&tcDetailId=" + tcDetailId + "&crflag=" + crflag;
                        // 财务部确认来款   财务做账
                        if (taskDefKey == keyNodes['006'] || taskDefKey == keyNodes['011']) {
                            reqParam += "&busid=" + dealId + "&taskDefKey=" + taskDefKey;
                        }
                        pageInTab.setTabItemSrc(tabid, targetUrl + reqParam);
                        break;
                }
                SetIframe_height();
            }
        });
    }

    // 保存上传的附件
    function saveAndUploadFile(fileId, gridIndex, flag) {
        ajaxFileUploadImg(fileId, function (fileData) {
            var docArray = [];
            docArray = docArray.concat(fileData);
            var data = {
                "docArray": JSON.stringify(docArray),
                "pkId": dealId,
                "flag": flag
            };
            AjaxUtils.ajaxPost(basePath + "/ass/assTrailCarD/uploadAttchment.do", data, function (msg) {
                if (msg.success == 1) {
                    if (msg.data) {
                        //刷新附件页面GRID方法和清空上传按钮
                        refreshUlFileRecList(gridIndex);
                    }
                } else {
                    UIUtils.alertError(msg.info);
                }
            }, true);
        });
    }


    //入库交接单
    function entryOrder(crflag) {
        var tcMasterId = $("#tcMasterId").val();//拖车主表ID
        var tcDetailId = $("#tcDetailId").val();//拖车明细ID
        var paySchId = $("#wsPaySchId").val();//支付表ID
        var paySchNo = $("#wsPaySchNo").val();//支付表号
        var prjId = $("#prjId").val();//项目ID
        var param = '&&tcMasterId=' + tcMasterId + '&&tcDetailId=' + tcDetailId + '&&crflag=' + crflag;
        param += '&&paySchId=' + paySchId + '&&paySchNo=' + paySchNo + '&&prjId=' + prjId;
        Add_navTab('entryOrder' + tcDetailId, '车辆交接单', basePath + '/ass/assTrailCarM/toWarehousePage.do?' + param);
    }

    //导出车辆交接单PDF
    function exportAssCarHvPdf() {
        var tcDetailId = $("#tcDetailId").val();//拖车明细ID
        window.location.href = basePath + '/ass/assTrailCarD/exportAssCarHvPdf.do?tcDetailId=' + tcDetailId;
    }
</script>
<%--流程各节点操作权限控制--%>
<jsp:include page="ucarDealFlowControl.jsp"></jsp:include>
</body>
</html>